package com.wxm.mqttintegrationdoc.controller;

import com.wxm.mqttintegrationdoc.service.MqttService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("topic")
public class MqttController {

    MqttService mqttService;
    @Autowired
    public MqttController(MqttService mqttService) {
        this.mqttService = mqttService;
    }

    @GetMapping
    public List<String> getTopics(){
        return mqttService.getTopics();
    }

    @PostMapping("/{topic}")
    public void addTopic(@PathVariable String topic){
        mqttService.addTopic(topic);
    }
    @DeleteMapping("/{topic}")
    public void delTopic(@PathVariable String topic){
        mqttService.removeTopic(topic);
    }
}
